<!-- 执行详情 -->
<template>
  <el-dialog
    :title="dialogTitle"
    :visible.sync="dialogVisible"
    width="35%"
    destroy-on-close
  >
    <div
      class="form-box"
      style="max-height: 500px; overflow: hidden; overflow-y: auto"
    >
      <el-form ref="executionDialogRef" :model="dialogForm" label-width="120px">
        <el-form-item label="表名：">
          <el-select
            v-model="tableName"
            placeholder="请选择"
            clearable
            style="width: 100%"
          >
            <el-option
              v-for="item in tableNameList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="共需写入：">
          <el-input v-model="dialogForm.writeReceivedRecords" disabled />
        </el-form-item>
        <el-form-item label="写入成功：">
          <el-input v-model="dialogForm.writeSucceedRecords" disabled />
        </el-form-item>
        <el-form-item label="写入失败：">
          <el-input v-model="dialogForm.writeFailedRecords" disabled />
        </el-form-item>
        <el-form-item label="共需读取：">
          <el-input v-model="dialogForm.totalReadRecords" disabled />
        </el-form-item>
        <el-form-item label="读取成功：">
          <el-input v-model="dialogForm.readSucceedRecords" disabled />
        </el-form-item>
        <el-form-item label="读取失败：">
          <el-input v-model="dialogForm.readFailedRecords" disabled />
        </el-form-item>
      </el-form>
    </div>
  </el-dialog>
</template>
<script>
export default {
  name: "executionDialog",
  data() {
    return {
      dialogTitle: "执行详情",
      dialogVisible: false,
      // 执行信息
      tableName: null,
      executeInfoMap: {},
      tableNameList: [],
    };
  },
  computed: {
    dialogForm() {
      if (this.tableName) {
        return this.executeInfoMap[this.tableName] || {};
      }
      return {};
    },
  },
  methods: {
    // 打开弹窗
    openDialog(info) {
      this.tableNameList = [];
      this.executeInfoMap = {};
      if (Array.isArray(info.detailList) && info.detailList.length) {
        this.tableNameList = info.detailList.map((item) => {
          this.executeInfoMap[item.tableName] = item;
          return {
            label: item.tableName,
            value: item.tableName,
          };
        });
        this.tableName = this.tableNameList[0]?.value;
      }
      this.dialogVisible = true;
    },
  },
};
</script>
<style scoped></style>
